package com.atguigu.rabbitmq.springbootmq.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @description: TODO 发布确认 mq配置
 * @author zhangbanglong
 * @date 2024/1/14 9:01
 * @version 1.0
 */
@Component
public class ConfirmConfig {

    public  static final String EXCHANGE_NM="confirm.exchange";
    public static final String QUEUE_NM="confirm.queue";

    @Bean("confirmExchange")
    public DirectExchange confirmExchange(){
        return new DirectExchange(EXCHANGE_NM);
    }

    @Bean("confirmQueue")
    public Queue confirmQueue(){
        return QueueBuilder.durable(QUEUE_NM).build();
    }

    @Bean
    public Binding queueBinding(@Qualifier("confirmQueue")Queue queue, @Qualifier("confirmExchange") DirectExchange exchange){
        return BindingBuilder.bind(queue).to(exchange).with("key1");
    }
}
